<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML>
<html>
<head>
    <base href="${ctx }/">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <link rel="stylesheet" href="plugin/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>
    <style type="text/css">
     ul{
     list-style-type: none;
     }
    span{
      margin-left:20px;
    }
    li{
    padding: 10px;
    }
    #content{
     margin-left: 60px;
    }
    </style>
</head>
<body>
  <div class="container-fluid">
    <div class="container row">
         <div>
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home home-icon"></i>
                    <a href="javascript:void(0)">Finance Management(财务管理)</a>
                </li>
                 <li class="active">
                    <a href="view/finance/weekly_settlement_setting.jsp">Payout Date(结算时间设置)</a>
                </li>
            </ul>
        </div>
    <!-- 内容 -->
        <div class="col-md-12">
            <form class="form-inline" id="updateform">
            <input type="hidden" id="ids" />
               <div class="form-group">
                <label for="bName">Payout Date&nbsp;:</label> 
                  <select id="week"  class="form-control">
                       <option value="2">Monday</option>
                       <option value="3">Tuesday</option>
                       <option value="4">Wednesday</option>
                       <option value="5">Thursday</option>
                       <option value="6">Friday</option>
                       <option value="7">Saturday</option>
                       <option value="1">Sunday</option>
                   </select> Week
                <input type="hidden" id="ids" />
            </div>  
                <br><br>
               <div style="margin-left: 100px;"><button class="btn btn-primary" onclick="return save()">Save</button></div> 
            </form>
        </div>
    </div>
</div>
</body>
<!-- 加载需要的js -->
<script src="js/jquery-3.2.1.min.js"></script>
<script src="plugin/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="plugin/layer/layer.js"></script>
<script type="text/javascript">
    $(function(){
    	initData();
    });
    function initData(){
		 $.ajax({
            type: "get",
            url: "configManager/getList",
            success: function(data){    	            	 
           if(data.code==200){
         	 $('#ids').val(data.data[0].id);
         	 $('#week').val(data.data[0].weeklySettlementSetting);
     	       }else{
     	    	    layer.msg(data.msg);
     	       }
                     }
        });
	}
    //保存
    function save(){
    	var week=$('#week').val();
    	if(week==""){
    		layer.msg("time is empty.");
    		return;
    	}
    	var id =$('#ids').val();
        var data={"id":id,"weeklySettlementSetting":week};
        $.ajax({
            type: "post",
            url: "configManager/addOrUpdate",
            data: JSON.stringify(data),
            contentType:"application/json;charset=UTF-8", 
            dataType:"json",
            success: function(data){    	            	 
           if(data.code==200){
         	  window.location.reload();
     	       }else{
     	    	    layer.msg(data.msg);
     	       }
                     }
        });
    }
</script>
</html>